/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is Forte for Java, Community Edition. The Initial * Developer of the Original Code is Sun Microsystems, Inc. Portions * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.vcs.cmdline.commands; import java.util.*; import org.openide.util.HelpCtx; /** * * @author Martin Entlicher * @version */ public class CvsRevisionChooser extends javax.swing.JDialog { static final long serialVersionUID =6001968409354417275L; /** Creates new form CvsRevisionChooser */ public CvsRevisionChooser(java.awt.Frame parent,boolean modal) { super (parent, modal); initComponents (); pack (); HelpCtx.setHelpIDString (getRootPane (), CvsRevisionChooser.class.getName ()); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the FormEditor. */ private void initComponents () {//GEN-BEGIN:initComponents infoLabel = new javax.swing.JLabel (); revisionScrollPane = new javax.swing.JScrollPane (); revisionList = new javax.swing.JList (); ocPanel = new javax.swing.JPanel (); okButton = new javax.swing.JButton (); cancelButton = new javax.swing.JButton (); getContentPane ().setLayout (new java.awt.GridBagLayout ()); java.awt.GridBagConstraints gridBagConstraints1; addWindowListener (new java.awt.event.WindowAdapter () { public void windowClosing (java.awt.event.WindowEvent evt) { closeDialog (evt); } } ); infoLabel.setText (org.openide.util.NbBundle.getBundle(CvsRevisionChooser.class).getString("CvsRevisionChooser.infoLabel.text")); gridBagConstraints1 = new java.awt.GridBagConstraints (); gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints1.insets = new java.awt.Insets (8, 8, 8, 8); gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints1.weightx = 1.0; getContentPane ().add (infoLabel, gridBagConstraints1); revisionList.setSelectionMode (javax.swing.ListSelectionModel.SINGLE_SELECTION); revisionScrollPane.setViewportView (revisionList); gridBagConstraints1 = new java.awt.GridBagConstraints (); gridBagConstraints1.gridy = 1; gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints1.insets = new java.awt.Insets (0, 8, 8, 8); gridBagConstraints1.weightx = 1.0; gridBagConstraints1.weighty = 1.0; getContentPane ().add (revisionScrollPane, gridBagConstraints1); ocPanel.setLayout (new java.awt.GridBagLayout ()); java.awt.GridBagConstraints gridBagConstraints2; okButton.setText (org.openide.util.NbBundle.getBundle(CvsRevisionChooser.class).getString("CvsRevisionChooser.okButton.text")); okButton.addActionListener (new java.awt.event.ActionListener () { public void actionPerformed (java.awt.event.ActionEvent evt) { okButtonActionPerformed (evt); } } ); gridBagConstraints2 = new java.awt.GridBagConstraints (); gridBagConstraints2.weightx = 1.0; ocPanel.add (okButton, gridBagConstraints2); cancelButton.setText (org.openide.util.NbBundle.getBundle(CvsRevisionChooser.class).getString("CvsRevisionChooser.cancelButton.text")); cancelButton.addActionListener (new java.awt.event.ActionListener () { public void actionPerformed (java.awt.event.ActionEvent evt) { cancelButtonActionPerformed (evt); } } ); gridBagConstraints2 = new java.awt.GridBagConstraints (); gridBagConstraints2.weightx = 1.0; ocPanel.add (cancelButton, gridBagConstraints2); gridBagConstraints1 = new java.awt.GridBagConstraints (); gridBagConstraints1.gridy = 2; gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints1.insets = new java.awt.Insets (0, 8, 8, 8); gridBagConstraints1.weightx = 1.0; getContentPane ().add (ocPanel, gridBagConstraints1); }//GEN-END:initComponents private void cancelButtonActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed // Add your handling code here: exit = CANCEL; closeDialog(null); }//GEN-LAST:event_cancelButtonActionPerformed private void okButtonActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed // Add your handling code here: exit = OK; closeDialog(null); }//GEN-LAST:event_okButtonActionPerformed /** Closes the dialog */ private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog setVisible (false); dispose (); }//GEN-LAST:event_closeDialog public void setCommandName(String name) { infoLabel.setText(name); infoLabel.repaint(); } public void setRevisions(Vector revisions) { javax.swing.DefaultListModel lm = new javax.swing.DefaultListModel(); Enumeration enum = revisions.elements(); while(enum.hasMoreElements()) { lm.addElement((String) enum.nextElement()); } revisionList.setModel(lm); revisionList.setSelectedIndex(0); pack(); } public String getRevision() { if (revisionList.isSelectionEmpty() || revisionList.getModel().getSize() == 0) return null; String revision = (String) revisionList.getSelectedValue(); int space = revision.indexOf(" "); // NOI18N if (space > 0) revision = revision.substring(space + 1, revision.length()); return revision; } public boolean showDialog() { show(); return exit == OK; } /** * @param args the command line arguments */ public static void main (String args[]) { new CvsRevisionChooser (new javax.swing.JFrame (), true).show (); } private int exit = NONE; private static final int NONE = 0; private static final int OK = 1; private static final int CANCEL = 2; // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JLabel infoLabel; private javax.swing.JScrollPane revisionScrollPane; private javax.swing.JList revisionList; private javax.swing.JPanel ocPanel; private javax.swing.JButton okButton; private javax.swing.JButton cancelButton; // End of variables declaration//GEN-END:variables }